<template>
	<view class="container">
		<view class="container-title">{{list.length}}人依次审批</view>
		<view class="container__body">
			<view class="container__body-users" v-for="(v,i) in list" :key="v.pxid">
				<view class="container__body-users-item">
					<view class="container__body-users-item-box">
						<view class="container__body-users-item-box-close" v-show="v.UserLock == '0'" @click="delUser(v,list)">
							<image src="@/static/theme/default/home/cha.png" mode=""></image>
						</view>
						<view class="container__body-users-item-box-avator">
							<avator :avator="v.avator" :name="v.pname"></avator>
						</view>
						<view class="container__body-users-item-box-name">{{v.pname}}</view>
					</view>
					<view class="container__body-users-item-symbol">></view>
				</view>
			</view>
			<view class="container__body-add" @click="goSelect">+</view>
		</view>
	</view>
</template>

<script>
	import _data from '@/common/_data.js'
	import Avator from '@/components/custom/avator/avator.vue'
	
	export default {
		components: {
			Avator
		},
		data() {
			return {
				list: [],
				index: '',
			}
		},
		onLoad(options) {
			this.list = JSON.parse(options.data)
			this.index = options.index;
		},
		onShow() {
			uni.$on('select-list',(v) => {
				this.list = v;
				_data.localData('select-list',[]);
			})
		},
		onUnload() {
			uni.$emit('select-list',this.list);
		},
		methods: {
			/**
			 * 格式化人名
			 * @param {Object} v
			 */
			formatName(v) {
				return v.length > 2 ? v.substring(v.length-2) : v
			},
			/**
			 * 跳转到选人界面
			 */
			goSelect() {
				_data.localData('select-list',this.list);
				uni.navigateTo({
					url: '/pages/wait/add/select',
				})
			},
			/**
			 * 删除人员
			 * @param {Object} v  待删除人员
			 * @param {Object} arr  当前审批数组
			 */
			delUser(v,arr) {
				arr.forEach((item,index) => {
					if(item.pxid == v.pxid) arr.splice(index,1)
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		
		&-title {
			height: 100rpx;
			font-size: 30rpx;
			line-height: 100rpx;
			color: #aaa;
			padding-left: 20rpx;
		}
		
		&__body {
			width: 100%;
			display: flex;
			flex-wrap: wrap;
			padding: 20rpx;
			box-sizing: border-box;
			
			&-add {
				width: 60rpx;
				height: 60rpx;
				font-size: 45rpx;
				color: #007AFF;
				border: 1rpx dotted #007AFF;
				text-align: center;
				line-height: 60rpx;
				border-radius: 10rpx;
			}
			
			&-users {
				margin-bottom: 30rpx;
				
				&-item {
					width: 100%;
					height: 100%;
					display: flex;
					
					&-box {
						position: relative;
						width: 100rpx;
						height: 100rpx;
						display: flex;
						flex-direction: column;
						justify-content: center;
						align-items: center;
						
						&-close {
							position: absolute;
							top: -25rpx;
							right: -10rpx;
							z-index: 9;
							width: 40rpx;
							height: 40rpx;
							background-color: #000;
							border-radius: 50%;
							display: flex;
							justify-content: center;
							align-items: center;
							
							image {
								width: 50%;
								height: 50%;
							}
						}
						
						&-avator {
							width: 80rpx;
							height: 80rpx;
						}
						
						&-name {
							font-size: 20rpx;
							color: #aaa;
						}
					}
					
					&-symbol {
						margin: 10rpx;
						color: #aaa;
						font-size: 30rpx;
					}
				}
			}
		}
	}
</style>
